#!/usr/bin/env bash
# Summary: Explain how the current Go version is set
# Usage: goenv version-origin

set -e
[ -n "$GOENV_DEBUG" ] && set -x

unset GOENV_VERSION_ORIGIN

OLDIFS="$IFS"
IFS=$'\n' scripts=(`goenv-hooks version-origin`)
IFS="$OLDIFS"
for script in "${scripts[@]}"; do
  source "$script"
done

if [ -n "$GOENV_VERSION_ORIGIN" ]; then
  echo "$GOENV_VERSION_ORIGIN"
elif [ -n "$GOENV_VERSION" ]; then
  echo "GOENV_VERSION environment variable"
else
  goenv-version-file
fi
